version: '3'

networks:
  ExTime:

volumes:
  dbvolume:

services:
  database:
    image: mysql
    container_name: mysql_db
    ports: 
      - "3306:3306"
    networks:
      - ExTime
    environment:
      - MYSQL_USER=dbuser
      - MYSQL_PASSWORD=123
      - MYSQL_DATABASE=extime_db
      - MYSQL_ROOT_PASSWORD=root
    volumes:
      - dbvolume:/var/lib/mysql

  backend:
    build: 
      context: ./ExTimeProject
    container_name: django_app
    ports:
      - "8000:8000"
    networks:
      - ExTime
    depends_on:
      - database
    # command: python manage.py runserver 0.0.0.0:8000
    command: >
      sh -c "python manage.py makemigrations &&
             python manage.py migrate --run-syncdb &&
             python manage.py runserver 0.0.0.0:8000"

  frontend:
    build:
      context: ./extime
    container_name: react_app
    ports:
      - "3000:3000"
    networks:
      - ExTime
    command: npm run start
